package com.kd.juhaowan.ui.holder;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;


import com.kd.juhaowan.R;
import com.kd.juhaowan.http.model.GiftModel;
import com.kd.juhaowan.http.model.GiftModel2;
import com.kd.juhaowan.ui.adapter.BaseViewHolder;
import com.kd.juhaowan.ui.listener.OnItemClickListener;
import com.kd.juhaowan.ui.listener.OnItemDianzanListener;

import butterknife.BindView;
import butterknife.OnClick;

public class GiftViewHolder extends BaseViewHolder {



    @BindView(R.id.item_gift_name)
    TextView nameView;
    @BindView(R.id.item_gift_des)
    TextView desView;
    @BindView(R.id.item_recive)
    TextView reciveView;
    @BindView(R.id.item_gift_tip)
    TextView tipView;





    public GiftViewHolder(@NonNull View itemView) {
        super(itemView);
    }
    @OnClick(R.id.item_recive)
    void onReciveClick(){
        OnItemClickListener listener = getOnItemClickListener();
        if(listener instanceof OnItemDianzanListener){
            ((OnItemDianzanListener) listener).onItemDianzanClick(this,getLayoutPosition());
        }
    }


    @SuppressLint("ResourceType")
    public void setDate(GiftModel model){
        nameView.setText(model.getName());
        desView.setText(model.getContent());
        if(model.getIs_receive()==0){
            reciveView.setTextColor(getContext().getColor(R.color.white));
            reciveView.setBackgroundResource(R.drawable.gift_btn_unrecive);
            reciveView.setText("领取");
            tipView.setText("剩余："+model.getResidue_number());
        }else{
            reciveView.setTextColor(getContext().getColor(R.color.c60));
            reciveView.setBackgroundResource(R.drawable.gift_btn_recived);
            reciveView.setText("复制");
            tipView.setText("礼包码："+model.getCode());
        }
    }
    @SuppressLint("ResourceType")
    public void setDate(GiftModel2 model){
        nameView.setText(model.getGiftpack_name());
        desView.setText(model.getContent());
        reciveView.setText("复制");
        tipView.setText("礼包码："+model.getCode());

    }


}
